<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\widgets\Pjax;
use backend\models\School;
use common\models\Person;

/* @var $this yii\web\View */
/* @var $model backend\models\Teacher */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="teacher-form">
    <?php //Pjax::begin(); ?>

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'XXID')->dropDownList(School::getSchoolID(), ['prompt'=>'请选择']); ?>

    <?= $form->field($model, 'GRID')->dropDownList(Person::getPersonID(), ['prompt'=>'请选择']); ?>

    <?php
    echo '<pre>';
    var_dump(Person::getPersonID());
    echo '</pre>';
    ?>

    <!-- <div class="personInfo" >
        <div class="form-group field-person-info required" style="padding-left: 0px">
            <label class="control-label" for="teacher-name" style="color: #999999">姓名</label>
            <input type="text" id="teacher-name" class="form-control" name="Teacher[name]"  aria-required="true">
            <div class="help-block"></div>
        </div>

        <div class="form-group field-person-info required" style="padding-left: 0px">
            <label class="control-label" for="teacher-sex" style="color: #999999">性别</label>
            <select id="teacher-sex" class="form-control" name="Teacher[sex]">
                <option value="1">男</option>
                <option value="0">女</option>
            </select>
            <div class="help-block"></div>
        </div>

        <div class="form-group field-person-info required" style="padding-left: 0px">
            <label class="control-label" for="teacher-birthday" style="color: #999999">出生日期</label>
            <input type="text" id="teacher-birthday" class="date form-control" name="Teacher[birthday]"  aria-required="true">
            <div class="help-block"></div>
        </div>

        <div class="form-group field-person-info required" style="padding-left: 0px">
            <label class="control-label" for="teacher-id_number" style="color: #999999">身份证号码</label>
            <input type="text" id="teacher-id_number" class="form-control" name="Teacher[id_number]" aria-required="true">
            <div class="help-block"></div>
        </div>
    </div> -->

    <?= $form->field($model, 'GH')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'BMID')->dropDownList(\backend\models\Department::getDepartID($model->XXID),['prompt'=>'请选择']); ?>

    <?= $form->field($model, 'ZYID')->dropDownList(\backend\models\Major::getMajorID($model->XXID),['prompt'=>'请选择']); ?>

    <?= $form->field($model, 'GWMC')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'ZW')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'ZC')->dropDownList(Yii::$app->params['fieldOptions']['ZC'],['prompt'=>'请选择']); ?>

    <?= $form->field($model, 'RZSJ')->textInput(['class'=>'date form-control']) ?>

    <?= $form->field($model, 'LRSJ')->textInput(['class'=>'date form-control']) ?>

    <?= $form->field($model, 'BZ')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'ZT')->dropDownList(Yii::$app->params['fieldOptions']['ZT'],['prompt'=>'请选择']); ?>

    <div class="form-group">
        <?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

    <?php //Pjax::end(); ?>

    <?php $this->render('//common/dialog'); ?>

    <script>
        <?php $this->beginBlock('person-item-form-js') ?>
        // 添加person选择面板
        function setPersonId(item) {
            if(item){
                $('#teacher-grid').removeClass('disabled');
                $('#teacher-grid').addClass('enable');
                $('#teacher-grid').val(item['id']);
                $('#teacher-name').val(item['name']);
                $('#teacher-sex').val(item['sex']);
                $('#teacher-birthday').val(item['birthday']);
                $('#teacher-id_number').val(item['id_number']);
            }else{
                $('#teacher-grid').val('');
                $('#teacher-name').val('');
                $('#teacher-sex').val('');
                $('#teacher-birthday').val('');
                $('#teacher-id_number').val('');
                $('#teacher-grid').removeClass('enable');
                $('#teacher-grid').addClass('disabled');
            }

            $('.person-form').submit();  // 提交表单
        }

        // 添加school选择面板
        function setSchoolId(item) {
            $('#teacher-xxid').val(item);

            $('.school-form').submit();  // 提交表单
        }

        // 选择person个人信息
        // $('#teacher-grid').on('click', function(){
        //     commonDialog('person-list', {title: '选择个人信息'}, setPersonId );
        //     return false;
        // });

        // 选择school信息
        // $('#teacher-xxid').on('click', function(){
        //     commonDialog('school-list', {title: '选择学校'}, setSchoolId );
        //     return false;
        // });

        <?php $this->endBlock(); ?>
        <?php $this->registerJs($this->blocks['person-item-form-js']);?>
    </script>
    <!-- layui日期选择器 -->
    <script>
    <?php $this->beginBlock('datepicker-config') ?>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        $('.date').each(function(){
            laydate.render({
              elem: this, //指定表单控件
            });
        });
    });
    <?php $this->endBlock() ?>
    <?php $this->registerJs($this->blocks['datepicker-config']) ?>
</script>
</div>
